const URL = 'www.baidu.com?key1=value1&key2=value2&key3=value3'
const searchParams = URL.split('?')[1]
console.log(searchParams)

// const res = {}
// const arr = searchParams.split('&')
// for (const iterator of arr) {
//     const keyValue =iterator.split('=')
//     res[keyValue[0]]=keyValue[1]
// }


// 2.
const res = {}
const params = new URLSearchParams(searchParams)
console.log(params)
for (const [key,value] of params) {
    res[key] = value
}

console.log(res)